package DO2;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 * Created by Cai Ye on 2016/4/12.
 */
public class ComplexOf20145208Test {

    @Test
    public void testComplex() throws Exception {
        assertEquals("7.0+9.0i", new ComplexOf20145208(2, 6).Add(new ComplexOf20145208(5, 3)).toString());
        assertEquals("-3.0+3.0i", new ComplexOf20145208(2, 6).Minus(new ComplexOf20145208(5, 3)).toString());
        assertEquals("10.0+18.0i", new ComplexOf20145208(2, 6).Multi(new ComplexOf20145208(5, 3)).toString());
    }

    @Test
    public void testAdd() throws Exception {
        assertEquals("7.0+9.0i", new ComplexOf20145208(2, 6).Add(new ComplexOf20145208(5, 3)).toString());
        assertEquals("7.0+9.0i", new ComplexOf20145208(2, 6).Add(new ComplexOf20145208(5, 3)).toString());
        assertEquals("-7.0+9.0i", new ComplexOf20145208(-2, 6).Add(new ComplexOf20145208(-5, 3)).toString());

    }

    @Test
    public void testMinus() throws Exception {
        assertEquals("-3.0+3.0i", new ComplexOf20145208(2, 6).Minus(new ComplexOf20145208(5, 3)).toString());
        assertEquals("-5.0+3.0i", new ComplexOf20145208(0, 6).Minus(new ComplexOf20145208(5, 3)).toString());
        assertEquals("-5.0+3.0i", new ComplexOf20145208(0, 6).Minus(new ComplexOf20145208(5, 3)).toString());
        assertEquals("7.0+3.0i", new ComplexOf20145208(2, 6).Minus(new ComplexOf20145208(-5, 3)).toString());
    }


    @Test
    public void testMulti() throws Exception {
        assertEquals("10.0+18.0i", new ComplexOf20145208(2, 6).Multi(new ComplexOf20145208(5, 3)).toString());
        assertEquals("-10.0+18.0i", new ComplexOf20145208(2, 6).Multi(new ComplexOf20145208(-5, 3)).toString());
        assertEquals("0.0", new ComplexOf20145208(0, 6).Multi(new ComplexOf20145208(5, 0)).toString());
        assertEquals("18.0i", new ComplexOf20145208(0, 6).Multi(new ComplexOf20145208(5, 3)).toString());
    }


}